<template>
  <van-nav-bar fixed placeholder @click-left="handleLeftClick" @click-right="handleRightClick">
    <template #left>
      <van-icon name="arrow-left" color="#000" v-if="leftArrow" size="17" />
      <span v-if="leftText">{{ title }}</span>
    </template>
    <template #right>
      <van-icon name="search" color="#000" size="19" v-if="rightIcon" />
    </template>
  </van-nav-bar>
</template>

<script setup>
import { useMyRouters } from '@/router';

defineProps({
  title: {
    type: String,
    default: ''
  },
  leftArrow: {
    type: Boolean,
    default: false
  },
  leftText: {
    type: Boolean,
    default: true
  },
  rightIcon: {
    type: Boolean,
    default: true
  }
});

const { router } = useMyRouters();

const handleLeftClick = () => {
  // router.back();
  history.back();
};

const handleRightClick = () => {
  router.push({
    path: '/search'
  });
};
</script>

<style lang="less" scoped>
.van-nav-bar__content {
  span {
    font-size: 16px;
    padding-left: 5px;
  }
}
</style>
